package com.bdd.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @Author Bdd
 * @Description
 * @Date 2020/4/2 15:07
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PageVo<T> {

    //当前页码
    private int currentNum;
    //每页显示条数
    private int size;
    //存储数据
    private List<T> data;
    //上一页
    private int pre;
    //下一页
    private int next;

    //总记录条数
    private int totals;

    public PageVo(int currentNum,int totals,int size){
        this.currentNum = currentNum < 1 ? 1 :currentNum;
        this.size = size;
        this.totals = totals;
        this.pre = currentNum - 1 < 1 ? 1 : currentNum - 1;
        int last = totals / size + totals % size > 0 ? 1 : 0;
        this.next = currentNum + 1 > last ? last : currentNum + 1;
    }




}
